/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model.Servicios;

import Model.Beans.Question;
import Model.DAO.AnswerDAO;
import Model.DAO.QuestionDAO;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Pashi
 */
public class QuestionSrv {
    private QuestionDAO qDAO = new QuestionDAO();
    private AnswerDAO aDAO = new AnswerDAO();

    public List<Question> getQuestions(){
        List<Question> questionsTemp = qDAO.getAll(Question.class);
        List<Question> questions = new ArrayList<Question>();
        for(Question q: questionsTemp){
            questions.add(qDAO.getQuestion(q.getIdquestion()));
        }
        return questions;
    }
    
    public void insertQuestion(Question question){
        qDAO.insertar(question);
    }

    public void deleteById(String idQ) {
        aDAO.deleteByQ(Integer.valueOf(idQ));
        qDAO.borrar(qDAO.getQuestion(Integer.parseInt(idQ)));
    }
    
    public Question getQuestion(String idQ){
    return qDAO.getQuestion(Integer.parseInt(idQ));
    }
}
